// encoding utf-8
#include "QyRenderItem.h"
#include "QyRenderLayer.h"

using namespace QyRender;

Item::Item( QyRender::Layer * layer ) : p_layer(0) {

	p_serial = QUuid::createUuid();
	setLayer(layer); // FIX:  вызов setLayer приводит к вызову виртуального метода

}

Item::~Item() {

	setLayer(0);

}

void Item::setLayer( QyRender::Layer * layer ) {

	if ( p_layer == layer )
		return;

	QyRender::Layer * oldLayer = p_layer;

	if (p_layer)
		p_layer->items().removeOne(this);

	p_layer = layer;

	if (p_layer)
		p_layer->items().append(this);

	layerChanged( oldLayer, layer );

}
